package com.javapda.c328r.command;

/**
 * 2-bit Gray Scale 01h
 * 4-bit Gray Scale 02h
 * 8-bit Gray Scale 03h
 * 12-bit Color 05h
 * 16-bit Color 06h
 * JPEG 07h
 *
 */
public abstract class ComediaPreviewColorType {
	public static final int GRAY_SCALE_2_BIT = 0x01;
	public static final int GRAY_SCALE_4_BIT = 0x02;
	public static final int GRAY_SCALE_8_BIT = 0x03;
	public static final int COLOR_12_BIT = 0x05;
	public static final int COLOR_16_BIT = 0x06;
	public static final int JPEG = 0x07;
	public static int convert(String code) {
		if ( code.equals("GRAY_SCALE_2_BIT") ) return GRAY_SCALE_2_BIT;
		if ( code.equals("GRAY_SCALE_4_BIT") ) return GRAY_SCALE_4_BIT;
		if ( code.equals("GRAY_SCALE_8_BIT") ) return GRAY_SCALE_8_BIT;
		if ( code.equals("COLOR_12_BIT") ) return COLOR_12_BIT;
		if ( code.equals("COLOR_16_BIT") ) return COLOR_16_BIT;
		if ( code.equals("JPEG") ) return JPEG;
		throw new RuntimeException("ERROR: unknown preview color type code: " + code);
	}
	public static String convert(int code) {
		if ( code == GRAY_SCALE_2_BIT ) return "GRAY_SCALE_2_BIT";
		if ( code == GRAY_SCALE_4_BIT ) return "GRAY_SCALE_4_BIT";
		if ( code == GRAY_SCALE_8_BIT ) return "GRAY_SCALE_8_BIT";
		if ( code == COLOR_12_BIT ) return "COLOR_12_BIT";
		if ( code == COLOR_16_BIT ) return "COLOR_16_BIT";
		if ( code == JPEG ) return "JPEG";
		throw new RuntimeException("ERROR: unknown preview color type code: " + code);
	}
}
